//
//  UIButton+Extension.swift
//  FWSinaWeibo
//
//  Created by 范伟 on 16/2/24.
//  Copyright © 2016年 FanWei. All rights reserved.
//

import UIKit

extension UIButton {
    ///便利构造函数创建按钮
    convenience init(fw_title title: String?,
        fonSize: CGFloat = 17,
        color: UIColor = UIColor.darkGrayColor(),
        imageName: String? = nil,
        backgroundImageName: String? = nil) {
            
            self.init()
            
            setTitle(title, forState: .Normal)
            setTitleColor(color, forState: .Normal)
            titleLabel?.font = UIFont.systemFontOfSize(fonSize)
            
            if let imageName = imageName {
                setImage(UIImage(named: imageName), forState: .Normal)
                setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
            }
            if let backgroundImageName = backgroundImageName {
                setBackgroundImage(UIImage(named: backgroundImageName), forState: .Normal)
                setBackgroundImage(UIImage(named: backgroundImageName + "_highlighted"), forState: .Highlighted)
            }
            //sizeToFit()
    }
}
